Microsoft DirectX 8.1 (C++)

CPosPassThru Class

CPosPassThru Base Class Hierarchy

The CPosPassThru class handles seek commands for filters with one input pin that do not perform seeking on their own.

This helper class implements the IMediaPosition and IMediaSeeking interfaces for filters that pass seek commands upstream. When the filter graph manager receives a seek command from an application, it delivers the command to the renderer filters in the graph. The command is then passed upstream through each filter's output pin, until it reaches a filter that can execute the command (if any). Typically, seeking is implemented on source filters or parser filters.

The CPosPassThru class holds a pointer to the filter's input pin. It passes seek commands to the connected output pin on the upstream filter, as shown in the following diagram.

CPossPassThru Class Passes Seek  Commands Upstream,

Use the CPosPassThru class for transform filters, and the derived CRendererPosPassThru class for renderer filters.

To use this class in your filter, create an instance of the class and specify the filter's input pin in the CPosPassThru constructor method. Then delegate all IMediaPosition and IMediaSeeking calls to the CPosPassThru object.

The simplest way to delegate seeking commands is to expose the CPosPassThru object's IMediaPosition and IMediaSeeking interfaces. When your filter or pin is queried for one of these interfaces, return a pointer to the CPosPassThru implementation of the interface. The following code shows how do this. It is adapted from the CTransformOutputPin class. The CreatePosPassThru function is a helper function that creates the CPosPassThru object:

// The following member variables are assumed:
IPin *m_pInput;    // Pointer to the input pin.
IUnknown *m_pPos;  // Pointer to the CPosPassThru object.

STDMETHODIMP CMyPin::NonDelegatingQueryInterface(REFIID riid, void **ppv)
{
    HRESULT hr
    if (riid == IID_IMediaPosition || riid == IID_IMediaSeeking) 
    {
        if (m_pPos == NULL) 
        {
            hr = CreatePosPassThru(GetOwner(), FALSE, m_pInput, &m_pPos);
            if (FAILED(hr)) return hr;
        }
        return m_pPos->QueryInterface(riid, ppv);
    } 
    else
    {
        /* Return pointers to the other interfaces on this pin.... */
    }
}

The CreatePosPassThru function leaves an outstanding reference count on the returned CPosPassThru object. Be sure to release it in your pin's destructor method:

~CMyPin::CMyPin() 
{
    if (m_pPos) m_pPos->Release();
}

Except where noted, all IMediaPosition and IMediaSeeking methods in this class call the corresponding method on the connected pin and return the result.

Requirements

Header: Declared in Ctlutil.h; include Streams.h.

Library: Use Strmbase.lib (retail builds) or Strmbasd.lib (debug builds).

Public Methods  
CPosPassThru Constructor method.
ForceRefresh Obsolete.
GetMediaTime Retrieves the time stamps on the current sample. Virtual.
IMediaPosition Methods  
get_Duration Retrieves the duration of the stream.
put_CurrentPosition Sets the current position, relative to the total duration of the stream.
get_StopTime Retrieves the time at which the playback will stop, relative to the duration of the stream.
put_StopTime Sets the time at which the playback will stop, relative to the duration of the stream.
get_PrerollTime Retrieves the amount of data that will be queued before the start position.
put_PrerollTime Sets the amount of data that will be queued before the start position.
get_Rate Retrieves the playback rate.
put_Rate Sets the playback rate.
get_CurrentPosition Retrieves the current position, relative to the total duration of the stream.
CanSeekForward Determines whether the stream can be seeked backward.
CanSeekBackward Determines whether the stream can be seeked forward.
IMediaSeeking Methods  
CheckCapabilities Queries whether a stream has specified seeking capabilities.
ConvertTimeFormat Converts from one time format to another.
GetAvailable Retrieves the range of times in which seeking is efficient.
GetCapabilities Retrieves all the seeking capabilities of the stream.
GetCurrentPosition Retrieves the current position, relative to the total duration of the stream.
GetDuration Retrieves the duration of the stream.
GetPositions Retrieves the current position and the stop position, relative to the total duration of the stream.
GetPreroll Retrieves the amount of data that will be queued before the start position.
GetRate Retrieves the playback rate.
GetStopPosition Retrieves the time at which the playback will stop, relative to the duration of the stream.
GetTimeFormat Retrieves the current time format.
IsFormatSupported Determines whether a specified time format is supported.
IsUsingTimeFormat Determines whether a specified time format is the format currently in use.
QueryPreferredFormat Retrieves the preferred time format for the stream.
SetPositions Sets the current position and the stop position.
SetRate Sets the playback rate.
SetTimeFormat Sets the time format.
Helper Functions  
CreatePosPassThru Creates a CPosPassThru or CRendererPosPassThru object.